@*Hdip Project 2013-14, Student Name:- Chris Pembroke,  Student Number:- x00115839*@
@model Exercise1Project.Models.BikeService

@{
    ViewBag.Title = "AdminEdit";
    
}

<div class="viewContainerDiv2">

    <h2>AdminEdit</h2>

@if (Model.StatusService != "Paid") { 
    <p>
        @Html.DropDownList("Items")&nbsp&nbsp
        @Html.DropDownList("Actions")
        &nbsp&nbsp&nbsp<button onclick="AddListItem()">ADD</button>
    </p>

    <div>
        @Html.LabelFor(model => model.SelectedItems, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.DropDownList("ServiceItems")
            &nbsp&nbsp&nbsp<button onclick="return RemoveListItem();">REMOVE</button>

        </div>
    </div>
}

    @using (Html.BeginForm())
    {
        @Html.AntiForgeryToken()

        <div class="form-horizontal">

            @Html.ValidationSummary(true)
            @Html.HiddenFor(model => model.ServiceID)

            <div class="form-group">
                <div class="col-md-10">
                    @if (Model.StatusService != "Paid") 
                    {
                        @Html.HiddenFor(model => model.SelectedItems)
                    }
                    else
                    {
                         @Html.LabelFor(model => model.SelectedItems, new { @class = "control-label col-md-2" })
                         @Html.TextAreaFor(model => model.SelectedItems, new { @readonly = "readonly", @disabled = "disabled", @rows = "3", @Cols = "100" })
                    }
                    @Html.ValidationMessageFor(model => model.SelectedItems)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.PartsCost, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @if (Model.StatusService != "Paid") 
                    {
                        @Html.EditorFor(model => model.PartsCost)
                    }
                    else
                    {
                        @Html.TextBoxFor(model => model.PartsCost, new { @readonly = "readonly", @disabled = "disabled" })
                    }
                    @Html.ValidationMessageFor(model => model.PartsCost)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.LabourCost, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @if (Model.StatusService != "Paid")
                    { 
                         @Html.EditorFor(model => model.LabourCost)
                    }
                    else
                    {
                        @Html.TextBoxFor(model => model.LabourCost, new { @readonly = "readonly", @disabled = "disabled" })
                    }
                    @Html.ValidationMessageFor(model => model.LabourCost)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.TotalPrice, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @if (Model.StatusService != "Paid")
                    { 
                         @Html.EditorFor(model => model.TotalPrice)
                         <input id="calculateTotalPrice" type="button" value="Calc Total" onclick="calcTotalPrice()" />
                    }
                    else
                    {
                        @Html.TextBoxFor(model => model.TotalPrice, new { @readonly = "readonly", @disabled = "disabled" })
                    }
                    @Html.ValidationMessageFor(model => model.TotalPrice)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Date, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @if (Model.StatusService != "Paid")
                    { 
                         @Html.TextBoxFor(model => model.Date, new { @class = "date-picker", @readonly = "readonly" })
                    }
                    else
                    {
                        @Html.TextBoxFor(model => model.Date, new { @readonly = "readonly", @disabled = "disabled" })
                    }
                    @Html.ValidationMessageFor(model => model.Date)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.StatusBikeInShop, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.DropDownList("StatusBikeInShop")
                    @Html.ValidationMessageFor(model => model.StatusBikeInShop)
                </div>
            </div>


            <div class="form-group">
                @Html.LabelFor(model => model.StatusService, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @if(Model.StatusService != "Paid")
                    { 
                    @Html.DropDownList("StatusService", ViewBag.StatusService as SelectList )
                    }
                    else
                    {
                        @Html.TextBoxFor(model => model.StatusService, new {@readonly = "readonly", disabled = "disabled"})
                    }
                    @Html.ValidationMessageFor(model => model.StatusService)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.QuotedPrice, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @if (Model.StatusService != "Paid")
                    { 
                         @Html.EditorFor(model => model.QuotedPrice)
                    }
                    else
                    {
                        @Html.TextBoxFor(model => model.QuotedPrice, new {@readonly = "readonly", disabled = "disabled"})
                    }
                    @Html.ValidationMessageFor(model => model.QuotedPrice)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.BikeID, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.TextBoxFor(model => model.BikeID, new { @readonly = "readonly", disabled = "disabled" })
                    @Html.ValidationMessageFor(model => model.BikeID)
                </div>
            </div>



            <div class="form-group">
                <div class="col-md-offset-2 col-md-10">
                    <input type="submit" value="Save" class="btn btn-default" /> &nbsp&nbsp&nbsp&nbsp @Html.ActionLink("To Search Page", "AdminSearches")
                </div>
            </div>
        </div>
    }

</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    <link href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.min.css" rel="stylesheet" type="text/css" />
    <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
    <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script>
    <link rel="stylesheet" href="@Url.Content("~/Content/customised.css")" />

@if (Model.StatusService != "Paid") { 
<script type="text/javascript" src="@Url.Content("/Scripts/AdminEdit.js")"></script>
    <script>
        function calcTotalPrice() {
            var partsCost = document.getElementById("PartsCost");
            var labourCost = document.getElementById("LabourCost");
            var totalCost = document.getElementById("TotalPrice");
            if (partsCost.value === "") {
                partsCost.value = 0.0;
            }
            if (labourCost.value === "") {
                labourCost.value = 0.0;
            }
            totalCost.value = parseFloat(labourCost.value) + parseFloat(partsCost.value);
        }
    </script>
}
}

